importScripts('https://cdn.jsdelivr.net/npm/workbox-sw@3.6.3/build/workbox-sw.min.js')

route = [
    [
        /\/\/fonts\./
        workbox.strategies.staleWhileRevalidate({
            cacheName: 'font'
        })
    ]
    [
        /\.(?:ttf|woff|woff2)/
        workbox.strategies.cacheFirst({
            cacheName: 'ico'
            plugins: [
              new workbox.expiration.Plugin({
                maxEntries: 99
              })
            ]
        })
    ]
    [
        /\.(?:png|jpg|jpeg|webp|svg|gif)/
        workbox.strategies.cacheFirst({
        cacheName: 'img',
        plugins: [
            new workbox.expiration.Plugin({
                maxEntries: 999
            })
        ]
        })
    ]
    [
        /.*\.(?:js|html|css)/
        workbox.strategies.cacheFirst({
            cacheName: 'res',
            plugins: [
              new workbox.expiration.Plugin({
                maxEntries: 999
              })
            ]
        })
    ]
    [
        /.*/
        new workbox.strategies.NetworkFirst()
    ]
]

do ->
    for i in route
        workbox.routing.registerRoute(i[0],i[1])

